home *** CD-ROM | disk | FTP | other *** search
/ BMUG Revelations / BMUG Revelations.toast / Programming / Programming Languages / Harvest C / MPW Int & Lib / Interfaces / TextEdit.h < prev    next >
Text File  |  1991-04-17  |  13KB  |  329 lines

  1. /************************************************************
  2.  
  3. Created: Sunday, January 6, 1991 at 10:11 PM
  4.     TextEdit.h
  5.     C Interface to the Macintosh Libraries
  6.  
  7.  
  8.         Copyright Apple Computer, Inc.    1985-1990
  9.         All rights reserved
  10.  
  11. ************************************************************/
  12.  
  13.  
  14. #ifndef __TEXTEDIT__
  15. #define __TEXTEDIT__
  16.  
  17. #ifndef __QUICKDRAW__
  18. #include <Quickdraw.h>
  19. #endif
  20.  
  21.  
  22. enum {
  23.  
  24.  
  25. /* Justification styles */
  26.     teJustLeft = 0,
  27.     teJustCenter = 1,
  28.     teJustRight = -1,
  29.     teForceLeft = -2,
  30.  
  31. /* new names for the Justification styles */
  32.     teFlushDefault = 0,                                 /*flush according to the line direction */
  33.     teCenter = 1,                                       /*center justify */
  34.     teFlushRight = -1,                                  /*flush right for all scripts */
  35.     teFlushLeft = -2,                                   /*flush left for all scripts */
  36.  
  37. /* Set/Replace style modes */
  38.     fontBit = 0,                                        /*set font*/
  39.     faceBit = 1,                                        /*set face*/
  40.     sizeBit = 2,                                        /*set size*/
  41.     clrBit = 3,                                         /*set color*/
  42.     addSizeBit = 4,                                     /*add size mode*/
  43.     toglBit = 5,                                        /*set faces in toggle mode*/
  44.  
  45. /* TESetStyle/TEContinuousStyle modes */
  46.     doFont = 1,                                         /* set font (family) number*/
  47.     doFace = 2,                                         /*set character style*/
  48.     doSize = 4,                                         /*set type size*/
  49.     doColor = 8,                                        /*set color*/
  50.     doAll = 15,                                         /*set all attributes*/
  51.     addSize = 16                                        /*adjust type size*/
  52. };
  53. enum {
  54.     doToggle = 32,                                      /*toggle mode for TESetStyle & TEContinuousStyle*/
  55.  
  56. /* offsets into TEDispatchRec */
  57.     EOLHook = 0,                                        /*[ProcPtr] TEEOLHook*/
  58.     DRAWHook = 4,                                       /*[ProcPtr] TEWidthHook*/
  59.     WIDTHHook = 8,                                      /*[ProcPtr] TEDrawHook*/
  60.     HITTESTHook = 12,                                   /*[ProcPtr] TEHitTestHook*/
  61.     nWIDTHHook = 24,                                    /*[ProcPtr] nTEWidthHook*/
  62.     TextWidthHook = 28,                                 /*[ProcPtr] TETextWidthHook*/
  63.  
  64. /* selectors for TECustomHook */
  65.     intEOLHook = 0,                                     /*TEIntHook value*/
  66.     intDrawHook = 1,                                    /*TEIntHook value*/
  67.     intWidthHook = 2,                                   /*TEIntHook value*/
  68.     intHitTestHook = 3,                                 /*TEIntHook value*/
  69.     intNWidthHook = 6,                                  /*TEIntHook value for new version of WidthHook*/
  70.     intTextWidthHook = 7,                               /*TEIntHook value for new TextWidthHook*/
  71.  
  72. /* feature or bit definitions for TEFeatureFlag */
  73.     teFAutoScr = 0,                                     /*00000001b*/
  74.     teFTextBuffering = 1,                               /*00000010b*/
  75.     teFOutlineHilite = 2,                               /*00000100b*/
  76.     teFInlineInput = 3,                                 /*00001000b*/
  77.     teFUseTextServices = 4,                             /*00010000b*/
  78.  
  79. /* action for the new "bit (un)set" interface, TEFeatureFlag */
  80.     TEBitClear = 0,
  81.     TEBitSet = 1                                        /*set the selector bit*/
  82. };
  83. enum {
  84.     TEBitTest = -1,                                     /*no change; just return the current setting*/
  85.  
  86. /*constants for identifying the routine that called FindWord */
  87.     teWordSelect = 4,                                   /*clickExpand to select word*/
  88.     teWordDrag = 8,                                     /*clickExpand to drag new word*/
  89.     teFromFind = 12,                                    /*FindLine called it ($0C)*/
  90.     teFromRecal = 16                                    /*RecalLines called it ($10)*/
  91. };
  92.  
  93. typedef pascal Boolean (*WordBreakProcPtr)(Ptr text, short charPos);
  94. typedef pascal Boolean (*ClikLoopProcPtr)(void);
  95.  
  96. struct TERec {
  97.     Rect destRect;
  98.     Rect viewRect;
  99.     Rect selRect;
  100.     short lineHeight;
  101.     short fontAscent;
  102.     Point selPoint;
  103.     short selStart;
  104.     short selEnd;
  105.     short active;
  106.     WordBreakProcPtr wordBreak;
  107.     ClikLoopProcPtr clikLoop;
  108.     long clickTime;
  109.     short clickLoc;
  110.     long caretTime;
  111.     short caretState;
  112.     short just;
  113.     short teLength;
  114.     Handle hText;
  115.     short recalBack;
  116.     short recalLines;
  117.     short clikStuff;
  118.     short crOnly;
  119.     short txFont;
  120.     Style txFace;                                       /*txFace is unpacked byte*/
  121.     char filler;
  122.     short txMode;
  123.     short txSize;
  124.     GrafPtr inPort;
  125.     ProcPtr highHook;
  126.     ProcPtr caretHook;
  127.     short nLines;
  128.     short lineStarts[16001];
  129. };
  130.  
  131. typedef struct TERec TERec;
  132. typedef TERec *TEPtr, **TEHandle;
  133.  
  134. typedef char Chars[32001];
  135. typedef Chars *CharsPtr,**CharsHandle;
  136.  
  137. struct StyleRun {
  138.     short startChar;                                    /*starting character position*/
  139.     short styleIndex;                                   /*index in style table*/
  140. };
  141.  
  142. typedef struct StyleRun StyleRun;
  143.  
  144. struct STElement {
  145.     short stCount;                                      /*number of runs in this style*/
  146.     short stHeight;                                     /*line height*/
  147.     short stAscent;                                     /*font ascent*/
  148.     short stFont;                                       /*font (family) number*/
  149.     Style stFace;                                       /*character Style*/
  150.     char filler;                                        /*stFace is unpacked byte*/
  151.     short stSize;                                       /*size in points*/
  152.     RGBColor stColor;                                   /*absolute (RGB) color*/
  153. };
  154.  
  155. typedef struct STElement STElement;
  156.  
  157. typedef STElement TEStyleTable[1777], *STPtr, **STHandle;
  158.  
  159. struct LHElement {
  160.     short lhHeight;                                     /*maximum height in line*/
  161.     short lhAscent;                                     /*maximum ascent in line*/
  162. };
  163.  
  164. typedef struct LHElement LHElement;
  165.  
  166. typedef LHElement LHTable[8001], *LHPtr, **LHHandle;    /* ARRAY [0..8000] OF LHElement */
  167.  
  168. struct ScrpSTElement {
  169.     long scrpStartChar;                                 /*starting character position*/
  170.     short scrpHeight;                                   /*starting character position*/
  171.     short scrpAscent;
  172.     short scrpFont;
  173.     Style scrpFace;                                     /*unpacked byte*/
  174.     char filler;                                        /*scrpFace is unpacked byte*/
  175.     short scrpSize;
  176.     RGBColor scrpColor;
  177. };
  178.  
  179. typedef struct ScrpSTElement ScrpSTElement;
  180.  
  181. typedef ScrpSTElement ScrpSTTable[1601];                /* ARRAY [0..1600] OF ScrpSTElement */
  182.  
  183. struct StScrpRec {
  184.     short scrpNStyles;                                  /*number of styles in scrap*/
  185.     ScrpSTTable scrpStyleTab;                           /*table of styles for scrap*/
  186. };
  187.  
  188. typedef struct StScrpRec StScrpRec;
  189. typedef StScrpRec *StScrpPtr, **StScrpHandle;
  190.  
  191. struct NullStRec {
  192.     long teReserved;                                    /*reserved for future expansion*/
  193.     StScrpHandle nullScrap;                             /*handle to scrap style table*/
  194. };
  195.  
  196. typedef struct NullStRec NullStRec;
  197. typedef NullStRec *NullStPtr, **NullStHandle;
  198.  
  199. struct TEStyleRec {
  200.     short nRuns;                                        /*number of style runs*/
  201.     short nStyles;                                      /*size of style table*/
  202.     STHandle styleTab;                                  /*handle to style table*/
  203.     LHHandle lhTab;                                     /*handle to line-height table*/
  204.     long teRefCon;                                      /*reserved for application use*/
  205.     NullStHandle nullStyle;                             /*Handle to style set at null selection*/
  206.     StyleRun runs[8001];                                /*ARRAY [0..8000] OF StyleRun*/
  207. };
  208.  
  209. typedef struct TEStyleRec TEStyleRec;
  210. typedef TEStyleRec *TEStylePtr, **TEStyleHandle;
  211.  
  212. struct TextStyle {
  213.     short tsFont;                                       /*font (family) number*/
  214.     Style tsFace;                                       /*character Style*/
  215.     char filler;                                        /*tsFace is unpacked byte*/
  216.     short tsSize;                                       /*size in point*/
  217.     RGBColor tsColor;                                   /*absolute (RGB) color*/
  218. };
  219.  
  220. typedef struct TextStyle TextStyle;
  221. typedef TextStyle *TextStylePtr, **TextStyleHandle;
  222.  
  223.  
  224. typedef short TEIntHook;
  225.  
  226. #ifdef __cplusplus
  227. extern "C" {
  228. #endif
  229. pascal void TEInit(void)
  230.     = 0xA9CC; 
  231. pascal TEHandle TENew(const Rect *destRect,const Rect *viewRect)
  232.     = 0xA9D2; 
  233. pascal void TEDispose(TEHandle hTE)
  234.     = 0xA9CD; 
  235. pascal void TESetText(const void *text,long length,TEHandle hTE)
  236.     = 0xA9CF; 
  237. pascal CharsHandle TEGetText(TEHandle hTE)
  238.     = 0xA9CB; 
  239. pascal void TEIdle(TEHandle hTE)
  240.     = 0xA9DA; 
  241. pascal void TESetSelect(long selStart,long selEnd,TEHandle hTE)
  242.     = 0xA9D1; 
  243. pascal void TEActivate(TEHandle hTE)
  244.     = 0xA9D8; 
  245. pascal void TEDeactivate(TEHandle hTE)
  246.     = 0xA9D9; 
  247. pascal void TEKey(short key,TEHandle hTE)
  248.     = 0xA9DC; 
  249. pascal void TECut(TEHandle hTE)
  250.     = 0xA9D6; 
  251. pascal void TECopy(TEHandle hTE)
  252.     = 0xA9D5; 
  253. pascal void TEPaste(TEHandle hTE)
  254.     = 0xA9DB; 
  255. pascal void TEDelete(TEHandle hTE)
  256.     = 0xA9D7; 
  257. pascal void TEInsert(const void *text,long length,TEHandle hTE)
  258.     = 0xA9DE; 
  259. pascal void TESetJust(short just,TEHandle hTE)
  260.     = 0xA9DF; 
  261. pascal void TEUpdate(const Rect *rUpdate,TEHandle hTE)
  262.     = 0xA9D3; 
  263. pascal void TextBox(const void *text,long length,const Rect *box,short just)
  264.     = 0xA9CE; 
  265. pascal void TEScroll(short dh,short dv,TEHandle hTE)
  266.     = 0xA9DD; 
  267. pascal void TESelView(TEHandle hTE)
  268.     = 0xA811; 
  269. pascal void TEPinScroll(short dh,short dv,TEHandle hTE)
  270.     = 0xA812; 
  271. pascal void TEAutoView(Boolean fAuto,TEHandle hTE)
  272.     = 0xA813; 
  273. #define TEScrapHandle() (* (Handle*) 0xAB4)
  274. pascal void TECalText(TEHandle hTE)
  275.     = 0xA9D0; 
  276. pascal short TEGetOffset(Point pt,TEHandle hTE)
  277.     = 0xA83C; 
  278. pascal Point TEGetPoint(short offset,TEHandle hTE)
  279.     = {0x3F3C,0x0008,0xA83D}; 
  280. pascal void TEClick(Point pt,Boolean fExtend,TEHandle h)
  281.     = 0xA9D4; 
  282. pascal TEHandle TEStylNew(const Rect *destRect,const Rect *viewRect)
  283.     = 0xA83E; 
  284. pascal void SetStylHandle(TEStyleHandle theHandle,TEHandle hTE)
  285.     = {0x3F3C,0x0005,0xA83D}; 
  286. pascal TEStyleHandle GetStylHandle(TEHandle hTE)
  287.     = {0x3F3C,0x0004,0xA83D}; 
  288. pascal void TEGetStyle(short offset,TextStyle *theStyle,short *lineHeight,
  289.     short *fontAscent,TEHandle hTE)
  290.     = {0x3F3C,0x0003,0xA83D}; 
  291. pascal void TEStylPaste(TEHandle hTE)
  292.     = {0x3F3C,0x0000,0xA83D}; 
  293. pascal void TESetStyle(short mode,const TextStyle *newStyle,Boolean redraw,
  294.     TEHandle hTE)
  295.     = {0x3F3C,0x0001,0xA83D}; 
  296. pascal void TEReplaceStyle(short mode,const TextStyle *oldStyle,const TextStyle *newStyle,
  297.     Boolean redraw,TEHandle hTE)
  298.     = {0x3F3C,0x0002,0xA83D}; 
  299. pascal StScrpHandle GetStylScrap(TEHandle hTE)
  300.     = {0x3F3C,0x0006,0xA83D}; 
  301. pascal void TEStylInsert(const void *text,long length,StScrpHandle hST,
  302.     TEHandle hTE)
  303.     = {0x3F3C,0x0007,0xA83D}; 
  304. pascal long TEGetHeight(long endLine,long startLine,TEHandle hTE)
  305.     = {0x3F3C,0x0009,0xA83D}; 
  306. pascal Boolean TEContinuousStyle(short *mode,TextStyle *aStyle,TEHandle hTE)
  307.     = {0x3F3C,0x000A,0xA83D}; 
  308. pascal void SetStylScrap(long rangeStart,long rangeEnd,StScrpHandle newStyles,
  309.     Boolean redraw,TEHandle hTE)
  310.     = {0x3F3C,0x000B,0xA83D}; 
  311. pascal void TECustomHook(TEIntHook which,ProcPtr *addr,TEHandle hTE)
  312.     = {0x3F3C,0x000C,0xA83D}; 
  313. pascal long TENumStyles(long rangeStart,long rangeEnd,TEHandle hTE)
  314.     = {0x3F3C,0x000D,0xA83D}; 
  315. pascal short TEFeatureFlag(short feature,short action,TEHandle hTE)
  316.     = {0x3F3C,0x000E,0xA83D}; 
  317. #define TEGetScrapLen() ((long) * (unsigned short *) 0x0AB0)
  318. pascal void TESetScrapLen(long length); 
  319. pascal OSErr TEFromScrap(void); 
  320. pascal OSErr TEToScrap(void); 
  321. pascal void SetClikLoop(ClikLoopProcPtr clikProc,TEHandle hTE); 
  322. pascal void SetWordBreak(WordBreakProcPtr wBrkProc,TEHandle hTE); 
  323. void teclick(Point *pt,Boolean fExtend,TEHandle h); 
  324. #ifdef __cplusplus
  325. }
  326. #endif
  327.  
  328. #endif
  329.